<template>
  <transition name="input-animation">
    <div class="container-input input-transition" v-if="isShow">
      <div class="item-input">
        <el-input :maxlength="maxlength" :placeholder="placeholder" :show-password="showPassword" :type="type" :value="value" @blur="$emit('blur')" @clear="$emit('clear')" @input="(value)=>$emit('input', value)" clearable />
      </div>
      <div class="container-item-tip">
        <transition name="input-animation">
          <span :class="['item-tip',state?'scucess':'error']" v-if="tip" v-text="tip" />
        </transition>
      </div>
    </div>
  </transition>
</template>

<script>
export default {
    name: 'ItemInput',
    props: {
        showPassword: Boolean,
        isShow: [Boolean, String],
        state: [Boolean, String],
        maxlength: [Number, String],
        value: String,
        tip: String,
        type: {
            type: String,
            default: 'text',
        },
        placeholder: {
            type: String,
            default: '请输入...',
        },
    },
};
</script>

<style lang="less" spcoed>
.container-input {
  display: flex;
  flex-direction: column;
  flex: 1;
  .el-input.is-active .el-input__inner,
  .el-input__inner:focus {
    border-color: #817487;
  }
  .el-input__inner {
    border: 1px solid;
    border-width: 1px;
    border-radius: @formRadius;
    font-weight: bold;
    color: #817487;
  }
}
.item-input {
  padding-top: 20px;
}
.container-item-tip {
  height: 20px;
  padding: 6px 0 10px;
  box-sizing: border-box;
  line-height: 20px;
  font-size: 12px;
  user-select: none;
}
.item-tip {
  display: block;
  width: 100%;
  transition: all 0.8;
  position: relative;
  z-index: 10;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-weight: bold;
  &.scucess {
    color: #909399;
  }
  &.error {
    color: #f56c6c;
  }
}
</style>
